home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
George Foreman's Interac…ng, Barbeque & Rotisserie
/
George Foreman's Interactive Guide to Grilling, Barbeque, and Rotisserie.iso
/
j
/
treemenu.js
< prev
Wrap
Text File
|
2002-10-22
|
13KB
|
387 lines
var pararray = new Array(); //holds flag of bar to display.
var targetIFrame='toc'; //holds name of targetted IFrame Object.
var bookTitle=''; //holds title of book to be displayed.
var bookIcon=''; //holds Icon of book to be displayed.
var imgPath=''; //holds Path string of images directory.
var valueAddedWindow;
var curFocus=0;
function showPopup(url) {
if (!valueAddedWindow || valueAddedWindow.closed) {
valueAddedWindow = window.open(url,'f001007pagevalueaddedmedia_window','height=540,width=760,resizable=1,scrollbars=yes,top=10,left=10');
} else {
valueAddedWindow.focus();
}
}
function treeExpand(n) {
curFocus=n
menuitems[n][3]=true;
setTimeout("treeDisplay()", 1);
}
function treeCollapse(n) {
curFocus=n
menuitems[n][3]=false;
setTimeout("treeDisplay()", 1);
}
function loadPage(link)
{
var temp1= 'pagenumber=';
var temp2 = '&p=';
var indexofpagenumber = link.indexOf(temp1);
if(indexofpagenumber==-1) {
return;
}
var indexofpointer = link.lastIndexOf(temp2);
//alert(indexofpagenumber);
//alert(indexofpointer);
var pagenumber = link.substring(indexofpagenumber+ temp1.length,indexofpointer );
var pointer = link.substring(indexofpointer+ temp2.length,link.length );
if(pointer=='') {
link = pagenumber;
} else {
link = pagenumber+'$'+pointer;
}
//alert(link);
if (targetIFrame=='view') {
parent.opener.fromTOC(link);
}
else {
parent.fromTOC(link);
}
}
function treeCreate(strArray) {
imgPath ='../../i/';
//alert(imgPath);
var curCnt;
for (cnt=0;cnt<menuitems.length;cnt++)
{
//if (cnt==curFocus)
// alert("Create Focus "+curFocus);
curCnt=cnt;
// the text that appears in TOC
var actualDisplay = menuitems[curCnt][1]
// the text that appears in the alt message of the each TOC link
var altDisplay = menuitems[curCnt][1]
var strMenu='<tr valign="top"><td valign="top" nowrap>'
if (cnt==curFocus)
strMenu='<tr valign="top"><td valign="top" nowrap><a style="cursor: pointer; cursor: hand;" name="focusPointer"></a>'
for (i=0; i<menuitems[cnt][0]; i++) {
if (pararray[cnt].substring(i,i+1)=='0')
strMenu+='<img src="' + imgPath + '9.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">';
else
strMenu+='<img src="' + imgPath + '1.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">';
}
if (cnt<menuitems.length-1 && menuitems[cnt][0]<menuitems[cnt+1][0])
{
var isChanged = false;
var folderPath = imgPath + '5.gif';
var isVideo = altDisplay.indexOf('<videoelement>');
if(isVideo!=-1) {
folderPath = imgPath + 'DXReaderVideo.png';
isChanged = true;
}
var isVideo = altDisplay.indexOf('<audioelement>');
if(isVideo!=-1) {
folderPath = imgPath + 'DXReaderAudio.png';
isChanged = true;
}
var isVideo = altDisplay.indexOf('<audioelement>');
if(isVideo!=-1) {
folderPath = imgPath + 'DXReaderAudio.png';
isChanged = true;
}
var isFigures = altDisplay.indexOf('<figureelement>');
if(isFigures!=-1) {
folderPath = imgPath + 'DXReaderFigures.png';
isChanged = true;
}
var isFeatures = altDisplay.indexOf('<featureelement>');
if(isFeatures!=-1) {
folderPath = imgPath + 'DXReaderFeatures.png';
isChanged = true;
}
var isMap = altDisplay.indexOf('<mapelement>');
if(isMap!=-1) {
folderPath = imgPath + 'DXReaderMaps.png';
isChanged = true;
}
var isChronologies = altDisplay.indexOf('<chronologyelement>');
if(isChronologies!=-1) {
folderPath = imgPath + 'DXReaderChronologies.png';
isChanged = true;
}
var isInteractiveMaps = altDisplay.indexOf('<interactivemapyelement>');
if(isInteractiveMaps!=-1) {
folderPath = imgPath + 'DXReaderInteractiveMaps.png';
isChanged = true;
}
var isImages = altDisplay.indexOf('<imageselement>');
if(isImages!=-1) {
folderPath = imgPath + 'DXReaderImages.png';
isChanged = true;
}
var isLives = altDisplay.indexOf('<liveselement>');
if(isLives!=-1) {
folderPath = imgPath + 'American Lives.png';
isChanged = true;
}
var mappingPast = altDisplay.indexOf('<mappingpast>');
if(mappingPast!=-1) {
folderPath = imgPath + 'Mapping the Past.png';
isChanged = true;
}
var reviewingpast = altDisplay.indexOf('<reviewingpast>');
if(reviewingpast!=-1) {
folderPath = imgPath + 'Re-Viewing the Past.png';
isChanged = true;
}
var milestones = altDisplay.indexOf('<milestones>');
if(milestones!=-1) {
folderPath = imgPath + 'Milestone.png';
isChanged = true;
}
if (menuitems[cnt][3])
{
strMenu+='<a style="cursor: pointer; cursor: hand;" href="javascript: parent.toc.treeCollapse('+cnt+')">'
if (pararray[cnt].substring(menuitems[cnt][0],menuitems[cnt][0]+1) == '1')
strMenu+='<img src="' + imgPath + '11.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
else
strMenu+='<img src="' + imgPath + '3.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
if(isChanged) {
strMenu+='<img src="' + folderPath + '" align="left" border="0" vspace="0" hspace="0" width="18" height="18"></a>'
} else {
strMenu+='<img src="' + imgPath + '6.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
}
}
else
{
strMenu+='<a style="cursor: pointer; cursor: hand;" href="javascript: parent.toc.treeExpand('+cnt+')">'
if (pararray[cnt].substring(menuitems[cnt][0],menuitems[cnt][0]+1) == '1')
strMenu+='<img src="' + imgPath + '12.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
else
strMenu+='<img src="' + imgPath + '4.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
if(isChanged) {
strMenu+='<img src="' + folderPath + '" align="left" border="0" vspace="0" hspace="0" width="18" height="18"></a>'
} else {
strMenu+='<img src="' + imgPath + '5.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
}
while(cnt<menuitems.length-1 && menuitems[curCnt][0]<menuitems[cnt+1][0])
cnt++;
}
}
else
{
if (cnt==999) {alert(pararray[cnt].substring(menuitems[cnt][0],menuitems[cnt][0]+1));alert(pararray[cnt]);}
if (pararray[cnt].substring(menuitems[cnt][0],menuitems[cnt][0]+1) == '1')
strMenu+='<img src="' + imgPath + '10.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
else
strMenu+='<img src="' + imgPath + '2.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
strMenu+='<img src="' + imgPath + '7.gif" align="left" border="0" vspace="0" hspace="0" width="18" height="18">'
}
// display only 40 charactres and full text in alt message
// this condition is to be applied to views only
if (targetIFrame=='view') {
if(actualDisplay.length > 40) {
var temp = actualDisplay.substring(0,40);
//alert(temp);
var index = temp.lastIndexOf('&');
var index1 = temp.indexOf(';',index);
if(index!=-1) {
if(index1 == -1){
//alert('adding remaining part');
var index2 = actualDisplay.indexOf(';',index);
//alert(index2);
temp = temp.substring(0,index);
temp = temp + actualDisplay.substring(index,index2);
//alert(temp);
}
}
actualDisplay = temp+" ...";
}
}
// if its link for video attach the icon for for video
var isVideo = altDisplay.indexOf('<video>');
if(isVideo!=-1) {
actualDisplay = '<img src="' +imgPath +'vi.png" border="0">' + actualDisplay;
altDisplay = altDisplay.substring(8,altDisplay.length);
}
// if its link for audio attach the icon for for audio
var isAudio = altDisplay.indexOf('<a style="cursor: pointer; cursor: hand;"udio>');
if(isAudio!=-1) {
actualDisplay = '<img src="' +imgPath +'au.png" border="0">' + actualDisplay;
altDisplay = altDisplay.substring(8,altDisplay.length);
}
// if its link for animation attach the icon for for animation
var isAnimation = altDisplay.indexOf('<a style="cursor: pointer; cursor: hand;"nima>');
if(isAnimation!=-1) {
actualDisplay = '<img src="' +imgPath +'ani.png" border="0">' + actualDisplay;
altDisplay = altDisplay.substring(8,altDisplay.length);
}
// if its link for quizes attach the icon for for quizes
var isQuize = altDisplay.indexOf('<quize>');
if(isQuize!=-1) {
actualDisplay = '<img src="' +imgPath +'qa.png" border="0">' + actualDisplay;
altDisplay = altDisplay.substring(8,altDisplay.length);
}
if (menuitems[curCnt][2] != '') {
if(isVideo!=-1) {
strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="' + menuitems[curCnt][2] + '\">'+actualDisplay+'</a>'
} else
if(isAudio!=-1) {
strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="' + menuitems[curCnt][2] + '\">'+actualDisplay+'</a>'
}else
if(isAnimation!=-1) {
strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="javascript:parent.toc.showPopup(\'' + menuitems[curCnt][2] + '\')">'+actualDisplay+'</a>'
}else
if(isQuize!=-1) {
strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="javascript:parent.toc.showPopup(\'' + menuitems[curCnt][2] + '\')">'+actualDisplay+'</a>'
}else
strMenu+=' <a style="cursor: pointer; cursor: hand;" title="'+altDisplay+'" onClick="javascript:parent.toc.loadPage(\'' + menuitems[curCnt][2] + '\')">'+actualDisplay+'</a>'
}
else {
strMenu+='<a style="cursor: pointer; cursor: hand;">'+menuitems[curCnt][1]+'</a>'
//alert(strMenu);
}
strMenu+='</td></tr>'
strArray[strArray.length]=strMenu;
//alert(strMenu);
}
}
function treeDisplay()
{
var strArray=new Array();
var strHTML = '';
if(top.os == 'Macintosh') {
strHTML ='<HTML><HEAD><script>function addFocus() { parent.tocdis.document.location.href="#focusPointer"; } </script><SCRIPT LANGUAGE="JavaScript" SRC="../../j/security.js"></SCRIPT><style>a {font-family: arial; font-size: 82%; text-decoration: none;}a:link {font-family: arial; font-size: 82%; text-decoration: none;}a:visited {font-family: arial; font-size: 82%; color: #ff0000; text-decoration: none;}a:hover {font-family: arial; font-size: 82%; color: #000000; font-weight: bold; text-decoration: underline;}</style></HEAD><BODY>';
} else {
strHTML ='<HTML><HEAD><script>function addFocus() { parent.tocdis.document.location.href="#focusPointer"; } </script><SCRIPT LANGUAGE="JavaScript" SRC="../../j/security.js"></SCRIPT><style>a {font-family: arial; font-size: 82%; text-decoration: none;}a:link {font-family: arial; font-size: 82%; text-decoration: none;}a:visited {font-family: arial; font-size: 82%; color: #ff0000; text-decoration: none;}a:hover {font-family: arial; font-size: 82%; color: #000000; font-weight: bold; text-decoration: underline;}</style></HEAD><BODY onload="addFocus()">';
}
strHTML+='<table cellspacing="0" cellpadding="0" border="0"><tr valign="top"><td nowrap class="btitle">'
fillIndentArray();
imgPath ='../../i/';
var displayTitle = bookTitle.substring(3,bookTitle.length-4);
if (bookIcon!='')
strHTML+='<img src="' + imgPath + bookIcon + '">'
strHTML+='<a style="cursor: pointer; cursor: hand;" title="'+displayTitle+'">'+bookTitle + '</a></td></tr>'
//creates HTML string for all nodes and adds to strHTML
treeCreate(strArray);
strHTML+=strArray.join(' ')
strHTML+='</table>'
strHTML+='</BODY></HTML>'
//alert(strHTML);
parent.tocdis.document.open();
parent.tocdis.document.write(strHTML);
parent.tocdis.document.close();
//document.getElementById("d1").innerHTML='';
//document.getElementById("d1").innerHTML=strHTML
}
function bstr(xx,str)
{
if (str.length>=xx)
{
if (str.length>xx)
return str.substring(0,xx);
else
return str.substring(0,xx-1) + '1';
}
else
return str.substring(0,str.length-1)+'1'+mystr('0',xx-str.length);
}
function mystr(chval,numval)
{
var k,stval;
stval='';
for (k=0;k<numval;k++)
stval=stval+'0';
return stval;
}
function fillIndentArray(arr)
{
var oldstr='00000';
var cnt;
for(cnt=menuitems.length-1;cnt>=0;cnt--)
{
pararray[cnt]=bstr(menuitems[cnt][0]+1,oldstr);
oldstr=pararray[cnt];
}
}